Write a C program that defines a 2-dimentional integer array
called A [50][50]. Then the elements of this array should
randomly be initialized either to 1 or 0. The program should
then print out all the elements in the diagonal (i.e.
a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally,
print out how many zeros and ones in the diagonal.

Answer Posted / pushpender singh

#include<stdio.h>

main
{
int a,b,c;
a[50][50];
b[][];
for(c=0;c>50;c+a)
{
a=a+c;
b=a;
}
printf("%d",b[][]);
}
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

653


What is the difference between strcpy() and memcpy() function in c programming?

626


Does * p ++ increment p or what it points to?

611


What are operators in c?

580


Do you know the difference between malloc() and calloc() function?

610






What are file streams?

565


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

2680


Explain how can I open a file so that other programs can update it at the same time?

587


What is cohesion in c?

537


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

603


Write a program of advanced Fibonacci series.

704


What is the use of header files?

600


What does != Mean in c?

583


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

718


Explain main function in c?

622