Sir,please help me out with the output of this programme:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a=18,b=12,i;
for(i=a<b?a:b;a%i||b%i;i--);
printf("%d %d",i);
}
Answers were Sorted based on User's Feedback
Answer / nilambuja
at starting of loop..
(i=12;6||0;i--)and it print 12 12
(i=11;7||1;i--)and it print 11 11
like wise 10 10 9 9 8 8 7 7
and when (i=6;0||0;i--)
the condition is false hence the crosser will come out of
the loop ..hence output will be... 12 12 11 11 10 10 9 9 8 8
7 7
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / manish soni bca 3rd year jaipu
hi frds,manis soni tagore collage jaipur
in this prm,
initily
for(i=12;a%i||b%i;i--);
--------|-------|--------|
a%i | b%i | i--;|
--------|-------|--------|
18%12=6*|** |12--=11;|
--------|-------|--------|
18%11=7*|** |11--=10;|
--------|-------|--------|
18%10=8*|** |10--=9; |
--------|-------|--------|
18%9=0 *|12%9=3 |9--=8; |
--------|-------|--------|
18%8=2 *|** |8--=7; |
--------|-------|--------|
18%7=4* |** |7--=6; |
--------|-------|--------|
18%6=0 *|12%6=0 |***; |
--------|-------|--------|
summory of the program
here we dissuss sum property
-----------------------------------
coition1||(or operaor)conditon 2;
-----------------------------------
in this case if condition1 is ture then
the second condition will not excute;
this is property of OR opr.
------------------------------------
here->(*)is represent condition1 and
------------------------------------
2.if c1 is false then c2 is true
this is represent **.
--------------------------------------
if c1 and c2 both are false then
***.
this is termination point.
and print 6;
bcoz at 6 both the condition are false.
| Is This Answer Correct ? | 0 Yes | 0 No |
Check how loop runs
At start of the loop for (I = 12; (18 % 12 || 12 % 12); i--)
1 ieteration  (6 || 0) and i = 11
1 ieteration  (7 || 1) and i = 10
1 ieteration  (0 || 3) and i = 9
1 ieteration  ( 2|| 4) and i = 8
1 ieteration  (4 || 5) and i = 7
1 ieteration  (0 || 0) and i = 6 Loop comes out then the
value of I prited is 6
| Is This Answer Correct ? | 1 Yes | 4 No |
Write a program with dynamically allocation of variable.
how to execute a program using if else condition and the output should enter number and the number is odd only...
Is it cc or c in a letter?
What is the difference between struct and typedef struct in c?
Write a C program linear.c that creates a sequence of processes with a given length. By sequence it is meant that each created process has exactly one child. Let's look at some example outputs for the program. Here the entire process sequence consists of process 18181: Sara@dell:~/OSSS$ ./linear 1 Creating process sequence of length 1. 18181 begins the sequence. An example for a sequence of length three: Sara@dell:~/OSSS$ ./linear 3 Creating process sequence of length 3. 18233 begins the sequence. 18234 is child of 18233 18235 is child of 18234 ........ this is coad .... BUt i could not compleate it .....:( #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int N; pid_t pid; int cont; if (argc != 2) { printf("Wrong number of command-line parameters!\n"); return 1; } N = atoi(argv[1]); printf("Creating process sequence of length %d.\n",N); printf("%d begins the sequence.\n",getpid()); /* What I have to do next ?????? */ }
What is a segmentation fault?
How can we see the Expanded source code and compiled code for our source program in C?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
all c language question
What does void main return?
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?
Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.