Posts

Showing posts with the label if else

GTU PPS Program - 20

Image
20. Write a program to find out sum of first and last digit of a given number. #include<stdio.h> #include<conio.h> int main() { int num,fd,ld,sum; printf("\nenter number : "); scanf("%d",&num); ld=num%10; while(num!=0) { if(num == ld) { fd=0; break; } else { fd=num%10; num=num/10; } } sum=fd+ld; printf("\nSum of first and last digit of given number is %d",sum); getch(); return 0; } sample output Previous Program Next Program

GTU PPS Program - 9

Image
9. Write a program to read marks of a student from keyboard whether the student is pass or fail. #include<stdio.h> #include<conio.h> int main() { int marks; printf("\nEnter your marks out of 100 : "); scanf("%d",&marks); if(marks>=33) printf("\nCongratulations! you passed the exam"); else printf("\nSorry! you failed, keep trying"); getch(); return 0; } Sample output Previous Program Next Program

YouTube