Professional Documents
Culture Documents
04
Class: 1 C
Reg: 098
Deadline : - The assignment is to be submitted (upload on portal) online till June 16, 2021. Viva
regarding assignment will be conducted after assignment deadline.
Problem 1: If a five-digit number is input through the keyboard, write a program to print
a new number by adding one to each of its digits. For example if the number that is input is
12391 then the output should be displayed as 23402.
Solution 1:
#include<stdio.h>
int main(){
scanf("%d",&number);
number_sum = number;
while(number_sum!=0){
number_sum=number_sum/10;
counter=counter+1;
}
for (x =1; x<counter; x++) {
num=num*10;
num=num+1;
total=number+num;
return 0;
56789
Problem 2 : Write a program which takes an integer number (assume number is 3 digit) as
an input and shows that the entered number is Armstrong or not. If sum of cubes of each
digit of the number is equal to the number itself, then the number is called an Armstrong
number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
Solution 2:
#include <stdio.h>
void main(){
int num,r,sum=0,temp;
scanf("%d",&num);
for(temp=num;num!=0;num=num/10){
r=num % 10;
sum=sum+(r*r*r);
if(sum==temp)
else
Solution 3:
#include <stdio.h>
#include <string.h>
void main()
int rl,phy,che,ca,total;
float per;
char nm[20],div[10];
scanf("%d",&rl);
scanf("%s",nm);
total = phy+che+ca;
per = total/3.0;
if (per>=60)
strcpy(div,"First");
else
if (per<60&&per>=48)
strcpy(div,"Second");
else
if (per<48&&per>=36)
strcpy(div,"Pass");
else
strcpy(div,"Fail");
Problem 4: Write a program converts a temperature from Celsius to Fahrenheit. Use the
following formula: F = 1.8 x C + 32 .
Solution:4
#include<stdio.h>
#include<conio.h>
int main () {
int celsius;
float fehrenteit;
printf (" Please enter celsius to convert
fehrenteit : ");
scanf("%d",&celsius);
fehrenteit = (float)1.8*celsius+32;
printf ("fehrenteit = %f ", fehrenteit);
getch ();
return 0;
}
Output: I give 50 celsious and enter
It gives 122,00000 ferenhite
Problem 5: Write a program that reads (inputs) three integers representing hours,
minutes, and seconds of a time. Then it calculates the equivalent time in seconds.
Solution : 5
#include<stdio.h>
return 0;
}
Input: I give 78 seconds enter
0:1:18