Simple

C++ Program to Add Two Numbers

Here you will get C++ program to add two numbers. The program will ask user to enter two numbers and then calculate their sum. #include<iostream> using namespace std; int main() { int x,y,sum; cout<<“Enter first no: “; cin>>x; cout<<“Enter second no: “; cin>>y; sum=x+y; cout<<“\nSum = “<<sum; return 0; } Output Enter first no: 4 …

C++ Program to Add Two Numbers Read More »

C program to raise any number x to a positive power n

#include<stdio.h> #include<conio.h> #include<math.h> void main() { int x,n,result; clrscr(); //to clear the scrren printf(“Enter value of x and n:”); scanf(“%d%d”,&x,&n); result=pow(x,n); printf(“nResult=%d”,result); getch(); //to stop the screen }

C program to print ASCII value of a character

#include<stdio.h> #include<conio.h> void main() { int a; char ch; clrscr(); //to clear the screen printf(“Enter any character:”); scanf(“%c”,&ch); a=ch; printf(“ASCII value of %c is %d”,ch,a); getch(); //to stop the screen }

C program that accepts marks in 5 subjects and outputs average marks

#include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e,average; clrscr(); printf(“Enter marks of subject 1:”); scanf(“%d”,&a); printf(“Enter marks of subject 2:”); scanf(“%d”,&b); printf(“Enter marks of subject 3:”); scanf(“%d”,&c); printf(“Enter marks of subject 4:”); scanf(“%d”,&d); printf(“Enter marks of subject 5:”); scanf(“%d”,&e); average=(a+b+c+d+e)/5; printf(“nAverage=%d”,average); getch(); }