0% found this document useful (0 votes)
30 views

Programming Language

This document contains a programming assignment with 3 questions. Question 1 asks to write a program to calculate total time in seconds from hours, minutes and seconds input by the user. Question 2 asks to write a program that accepts a character and displays its ASCII value. Question 3 asks to write a program to swap the values of two variables without using a third variable. The document provides sample code for each question's answer.

Uploaded by

biso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Programming Language

This document contains a programming assignment with 3 questions. Question 1 asks to write a program to calculate total time in seconds from hours, minutes and seconds input by the user. Question 2 asks to write a program that accepts a character and displays its ASCII value. Question 3 asks to write a program to swap the values of two variables without using a third variable. The document provides sample code for each question's answer.

Uploaded by

biso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Subject

Programming Fundamental
Assignment No 01 Marks 20

Q1: Write a program which asks the user to enter Hours, minutes and
seconds and then calculate

the total time in seconds and display it.


(5)

Q2: Write a program which accepts a character and display its ASCII
value. (5)

Q3: Write a program to swap the values of two variables without using
third variable. (10)
Question 1: Write a program which asks the
user to enter Hours, minutes and seconds and then
calculate the total time in seconds and display it

Answer:
PROGRAM
#include<iostream.h>

#include<conio.h>

int main()

int x , y, z, total;

cout<<" enter the value of x = hour y = minutes and z = seconds \n";

getch();

}
Output:
QUESTION 2:Which program accepts a character
and display its ASCII value?

Answer:

Program:
#include<iostream.h>

#include<stdlib.h>

int main()

char ascii;

int numeric;

cout << "Give character: ";

cin >> ascii;

cout << "Its ascii value is: " << (int) ascii << endl;

cout << "Give a number to convert to ascii: ";

cin >> numeric;

cout << "The ascii value of " << numeric << " is " << (char) numeric;

system(PAUSE);

}
Output:
Question 3: Write a program to swap the values of two
variables without using third variable

Answer:

Program:
#include <iostream.h>
#include <stdlib.h>
int main()
{
int x, y, temp;
x = 10;
y = 20;

cout<<"Before exchange" <<endl;


cout<<"x = "<< x << endl;
cout<<"y = "<< y << endl;

temp = x;
x = y;
y = temp;

cout<<"After exchange" <<endl;


cout<<"x = "<< x << endl;
cout<<"y = "<< y << endl;

system("PAUSE");
}
Output:

You might also like