Computer Science, asked by taniya55555, 1 year ago

Heya Friends,


While Loop and do while loop (only input needed)

(1) WAP to input a number and find the largest and smallest number in it
(2) WAP to input a number and check if its a special number or not
(3) WAP to input a number and find the sum of its digit (only do while loop)
(4) WAP to input a number and find the sum of its odd and even number separately


taniya55555: ok
chinmay1312: u requested me, put requests of biology till class 12th and science questions till class 10th. i don't have knowledge of computer science
chinmay1312: no dear... a request came
taniya55555: what request??
taniya55555: and @ajayrawat I'm not a boy
taniya55555: hmm it's OK

Answers

Answered by rakeshmohata
7
Hope U like My process
======================
I Did them on my own and runned them
And it really worked.

So.. The codes for respective questions are..
_-_-_-_-_-_-_-_-_--_-_-_-_-_-_-_-_-_-_
1)

#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,i,d,c;
printf("enter a number: ");
scanf("%d",&i);
d= i%10;
a=d;
i=i/10;
c=i%10;
b=c;
while(i>0)
{if(d<c)
{b=d;}
if(d>=a)
{a=d;
}
i=i/10;
d=i%10;
c=b;
}
printf("the largest number is %d \n and \n the smallest number is %d",a,b);

getch();

}

__________________________
2)
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c=1,d,i,sum=0;
printf("Enter a number: ");
scanf("%d",&a);
d= a;
while(a>0)
{
b=a%10;
for(i=1;i<=b;i++)
{ c=c*i;}
sum=sum+c;
a =a/10;
c =1;
}printf("sum = %d \n",sum);
if(sum==d)
{printf("the entered number is a special number.");};
if(sum!=d)
{printf("the entered number is not a special number." );}
getch();
}
_____________________________
3)
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main ()
{
int number = 0, digit = 0, sumOfDigits = 0;
clrscr();
printf("Enter any number\n ");
scanf("%d", &number);
do
{
digit = number % 10;
sumOfDigits = sumOfDigits + digit;
number = number / 10;
}while (number != 0);
printf ("Sum of individual digits of a given number is %d", sumOfDigits);
getch();
}
_________________________
4)
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a=0,b=0,c,i,d;
printf("Enter a number: ");
scanf("%d",&i);
while(i>0)
{
c=i%10;
d=c%2;
if(d==1)
{
a=a+c;
}
if(d==0)
{
b=b+c;
}
i=i/10;

}
printf("the sum of all odd digits is %d",a);
printf("\n the sum of all even digits is %d",b);

getch();
}
______________________________
Hope this are your required answer❤️

Proud to help you. ❤️
Attachments:

taniya55555: thank you thank you so much
rakeshmohata: welcome!! ❤️❤️
HappiestWriter012: Awesome!
rakeshmohata: thanks alot nrother
rakeshmohata: brother*
rakeshmohata: thanks for the brainliest one
Answered by adarshbpml
0

Answer:

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loops

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:for (i=0; i <= n; i++)

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:for (i=0; i <= n; i++)Python doesn't have this kind of loop.

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:for (i=0; i <= n; i++)Python doesn't have this kind of loop.- Condition-controlled loop

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:for (i=0; i <= n; i++)Python doesn't have this kind of loop.- Condition-controlled loopA loop will be repeated until a given condition changes, i.e. changes from True to False or from False to True, depending on the kind of loop. There are while loops and do while loops with this behaviour.

Many algorithms make it necessary for a programming language to have a construction which makes it possible to carry out a sequence of statements repeatedly. The code within the loop, i.e. the code carried out repeatedly, is called the body of the loop.Essentially, there are three different kinds of loops:- Count-controlled loopsA construction for repeating a loop a certain number of times. An example of this kind of loop is the for-loop of the programming language C:for (i=0; i <= n; i++)Python doesn't have this kind of loop.- Condition-controlled loopA loop will be repeated until a given condition changes, i.e. changes from True to False or from False to True, depending on the kind of loop. There are while loops and do while loops with this behaviour.-

Similar questions