Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Source code:

1.

#include<stdio.h>

int main()

int n;

scanf("%d",&n);

if(n>0){

printf("%d is positive\n",n);

else if(n==0){

printf("%d is zero\n",n);

else{

printf("%d is negative\n",n);

return 0;

2.

#include<stdio.h>

int main()

int y;
scanf("%d",&y);

if((y%4==0&&y%100!=0)||(y%400==0)){

printf("%d is leapyear",y);

else{

printf("%d is not a leapyear",y);

return 0;

3.

#include<stdio.h>

int main()

char ch;

scanf("%c",&ch);

if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')){

printf("%c is alphabet\n",ch);

else if(ch>=0&&ch<=9){

printf("%c is digit\n",ch);

else{

printf("%c is special character\n",ch);


}

return 0;

4.

#include<stdio.h>

int main()

char ch;

scanf("%c",&ch);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){

printf("%c is vowel\n",ch);

else{

printf("%c is consonant\n",ch);

return 0;

5.

#include<stdio.h>

int main()

int a,b,c;

scanf("%d%d%d",&a,&b,&c);

if((a+b>c)&&(a+c>b)&&(b+c>a)){
printf("triangle is valid\n");

else{

printf("triangle is not valid\n");

return 0;

6.

#include<stdio.h>

int main()

double physics,chemistry,biology,mathemetics,computer,percentage;

scanf("%lf%lf%lf%lf%lf",&physics,&chemistry,&biology,&mathemetics,&computer) ;

percentage=((physics+chemistry+biology+mathemetics+computer)/500)*100;

if(percentage>=90){

printf("Grade A\n");

else if(percentage>=80){

printf("Grade B\n");

else if(percentage>=70){

printf("Grade c\n");

}
else if(percentage>=60){

printf("Grade D\n");

else if(percentage>=40){

printf("Grade E\n");

else{

printf("Grade F\n");

return 0;

Given program:

7.

#include<stdio.h>

main()

int x=100;

printf("%d\n",10 + x++);

printf("%d\n",10 + ++x);

8.

#include<stdio.h>

main()
{

int x=5,y=10,z=10;

x= y==z;

printf("%d\n",x);

Sample Input & Output:

4.
5

You might also like