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

CPP

Uploaded by

radhikasn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

CPP

Uploaded by

radhikasn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Write C-Program to print a sentence

#include<stdio.h>
void main()
{
printf(“WELCOME TO JNNCE”);
}

2. Write C-Program to print a sentence with new line

#include<stdio.h>
void main()
{
printf(“WELCOME TO JNNCE\n”);
printf(“WELCOME TO C PROGRAMMING”);
}

3. Write C-Program to print a sentence with new line and tab

#include<stdio.h>
void main()
{
printf(“WELCOME TO JNNCE\t MECH\n”);
printf(“WELCOME TO C PROGRAMMING”);
}

4. Write C-Program to ADD two integers

#include<stdio.h>
void main()
{
int a,b,c;
a=10;
b=20;
c=a+b;
printf(“ Addition of two numbers c=%d”,c);
}
5. Write C-Program to calculate SUM and Average of three integers

#include<stdio.h>
void main()
{
int a,b,c,sum,avg;
a=10;
b=20;
c= 30;
sum=a+b+c;
avg=sum/3;
printf(“ Sum of three numbers sum=%d”,sum);
printf(“ Average of three numbers avg=%d”,avg);
}

6. Write C-Program to perform all arithmetic operation

#include<stdio.h>
void main()
{
int a,b,add,sub,mul,div;
a=10;
b=20;
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
printf(“ Addition of two numbers add=%d\n”,add);
printf(“ Substraction of two numbers sub=%d\n”,sub);
printf(“ Multiplication of two numbers mul=%d\n”,mul);
printf(“ Division of two numbers div=%d”,div);
}

7. Write C-Program to ADD two floating point numbers

#include<stdio.h>
void main()
{
float a,b,c;
a=10;
b=20;
c=a+b;
printf(“ Addition of two floating point numbers c=%f”,c);

8. Write C-Program to calculate sum and average of three floating point


numbers

#include<stdio.h>
void main()
{
float a,b,c,sum,avg;
a=10;
b=20;
c=30
sum=a+b+c;
avg=sum/3;
printf(“ Sum of three numbers sum=%f”,sum);
printf(“ Average of three numbers avg=%f”,avg);
}

INPUT FUNCTIONS ------SCANF()

9. Write C-Program to READ two integers

#include<stdio.h>
void main()
{
int a,b;
printf(“Enter a num \n”);
scanf(“%d”,&a);
printf(“Enter a num \n”);
scanf(“%d”,&b);
}
10.Write C-Program to READ two integers and ADD two integers

#include<stdio.h>
void main()
{
int a,b,add;
printf(“Enter a num \n”);
scanf(“%d”,&a);
printf(“Enter a num \n”);
scanf(“%d”,&b);
add=a+b;
printf(“add=%d”,add);
}

11.Write C-Program to calculate SUM and Average of three integers

#include<stdio.h>
void main()
{
int a,b,c,sum,avg;
printf(“Enter a num \n”);
scanf(“%d”,&a);
printf(“Enter a num \n”);
scanf(“%d”,&b);
sum=a+b+c;
avg=sum/3;
printf(“ Sum of three numbers sum=%d”,sum);
printf(“ Average of three numbers avg=%d”,avg);
}
12.

You might also like