answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

When loops are nested does one loop have to end before the other begins?

If one loop ends before the next begins then they are not nested at all -- they are completely independent. To be nested, one loop must contain the other loop in its entirety. That is, the inner, nested loop must start and end within the outer, containing loop.

Nested loop example (in C++):

for( int x = 0; x < 10; ++x ) // outer loop

{

for( int y = 0; y < 10; ++y ) // inner loop (nested loop)

{

printf( "%d x %d = %d\r\n", x, y, x*y );

} // end of inner loop

} // end of outer loop

Write a program to calculate GPA in C plus plus?

#include

#include

using namespace std;

int main ()

{

cout << endl << "Please enter all the grades you wish to use for your GPA." << endl;

cout << endl << "When you have finished, enter N to indicate that you have no more grades." << endl;

cout << endl << "The highest acceptable grade is 100%, if you got higher than this congratulations but please enter only 100 as grade." << endl;

cout << endl;

float Grade = 0;

int NumClass = 0;

const int Stop = -1;

float GPAVal = 0;

float TotGPAVal = 0;

float GPA = 0;

string SemName;

while (SemName != -1)

{

cout << "Please enter name of the semester of grades you want to enter." << endl;

cin >> SemName;

cout << SemName << endl;

do {

cout << endl << "Please enter grade: ";

cin >> Grade;

if ( Grade <=100 && Grade >= 90 )

{

GPAVal = 4.0;

cout << "Grade: " << Grade << "%; GPA Value: 4.0" << endl;

TotGPAVal = TotGPAVal + GPAVal;

}

else if ( Grade < 90 && Grade >= 80 )

{

GPAVal = 3.0;

cout << "Grade: " << Grade << "%; GPA Value: 3.0" << endl;

TotGPAVal = TotGPAVal + GPAVal;

}

else if ( Grade < 80 && Grade >= 70 )

{

GPAVal = 2.0;

cout << "Grade: " << Grade << "%; GPA Value: 2.0" << endl;

TotGPAVal = TotGPAVal + GPAVal;

}

else if ( Grade < 70 && Grade >= 60 )

{

GPAVal = 1.0;

cout << "Grade: " << Grade << "%; GPA Value: 1.0" << endl;

TotGPAVal = TotGPAVal + GPAVal;

}

else if ( Grade < 60 && Grade >= 0 )

{

GPAVal = 0.0;

cout << "Grade: " << Grade << "%; GPA Value: 0.0" << endl;

TotGPAVal = TotGPAVal + GPAVal;

}

else if ( Grade = Stop )

{

GPA = (TotGPAVal / NumClass);

cout << endl<< "Your overall GPA, after " << NumClass << " courses, is " << GPA << "." << endl << endl;

}

NumClass = NumClass + 1;

}

while (( Grade >= 0 ) && ( Grade <=100 ));

if (SemName = -1)

{

cout << "Thank you for using this program!" << endl;

}

}

return (0);

}

What is the purpose of the state array in AES?

Sub byte uses an S-box to perform a byte-by-byte substitution of the block. The left most 4 bits of the byte are used as row value and the rightmost 4 bits are used as a column value. These row and column values serve as indexes into the S-box to select a unique 8-bit value.

Write a program to overload preincrement and postincrement operator?

#include<iostream.h>

#include<conio.h>

class num

{

private:

int a,b,c,d;

publ;ic:

num(int j,int k,int m,int l)

{

a=j;

b=k;

c=m;

d=l;

}

void show(void);

void operator++();

};

void num::show()

{

cout<<...................................................................

}

void num::operator++()

{++a;++b;++c;++d;

}

main()

{

clrscr();

num X(3,2,5,7);

cout<<"b4 inc of x";

X.show();

++X;

cout<<"after inc of x";

X.show();

return 0;

}

Banking operations in c programm?

here is c code for banking system....

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <dos.h>

#include<string.h>

#include <graphics.h>

#define LEN 100

/*====================================================================*/

What is a header file and library function?

header files are predefined in c, they include the all necessary function to u to do your work easy instead of writing a function for printing a message or to read a input form key board we are using the library functions which are in the header files.

there are different types of header files depending upon the requirement we use them.

Write a Program for ascending order in 8085 microprocessor?

Source program :

  • MVI D, COUNT : Initialize counter
  • MVI B, 00 : Initialize variable to store previous number
  • MVI C, 01 : Initialize variable to store current number
  • MOV A, B :[Add two numbers]
  • BACK: ADD C :[Add two numbers]
  • MOV B, C : Current number is now previous number
  • MOV C, A : Save result as a new current number
  • DCR D : Decrement count
  • JNZ BACK : if count 0 go to BACK
  • HLT : Stop.

Who invented c sharp programming?

It wasn't really invented. It was designed by some Microsoft division, based on best in area tendencies to the point of time. A lot of concepts was taken directly from Java programming language.

What you mean by row major and column major?

its the method for sorting the multidimensional array.

eg:

consider the matrix: 10 1 3

2 7 5

8 6 4

row-major order: 1 3 10

2 5 7

4 6 8

column major order: 2 1 3

8 6 4

10 7 5

C program convert hours to minutes?

#include <stdlib.h>

#include <stdio.h>

int hoursToMinutes( int hours ){ return 60 * hours; }

int main(int argc, char *argv){

if(argc != 2)

return 1;

printf("%i\n", hoursToMinutes(atoi(argv[1])));

return 0;

}

When a language has the capability to produce new data type is also called?

New, compared to what? I guess you meant user-defined data-types, which exist in almost every modern programming language.

Write a c program to print multiplication table using while loop?

void main()

{

int a,b,c,d;

clrscr();

printf("\n Enter the number for table = ");

scanf("%d",&a);

printf("\n Enter the number up to which you want to see the table = ");

scanf("%d",&b);

for(c=1;c<=b;c++)

{

d=a*c;

printf("%d * %d = %d\n", a,c,d);

}

getch();

}

Which programming language uses a string of 1s and 0s?

You, as a programmer, can use a string with 1s and and 0s (or any other content) in each and every programming language.

Where are trees in data structures implemented in the real world?

First off, there are several types of trees in data structures. each with different uses and benefits. The two most common are binary trees and binomial trees.

Binary trees are used most commonly in search algorithms. The benefits of this is that a search can be performed in O(lg(n)) time, instead of the O(n) time that a sequential search takes. An example from the real world of a binary tree in action is in databases, where indexes are organized in a binary tree, thus enabling faster searching.

Binomial trees are usually used in communication, particularly when distributing or aggregating information. A real world example comes from supercomputers, where multiple processors are all working simultaneously. In order to aggregate or distribute data, a binomial tree structure is commonly employed.

Using conditional operator find a biggest number among two numbers?

Here is an example in Java: int a = 5; int b = 7; System.out.println(a > b ? a : b);

Here is an example in Java: int a = 5; int b = 7; System.out.println(a > b ? a : b);

Here is an example in Java: int a = 5; int b = 7; System.out.println(a > b ? a : b);

Here is an example in Java: int a = 5; int b = 7; System.out.println(a > b ? a : b);

What do mean by structural programming?

Structured programming is a programming paradigm. Prior to structured programming, code was typically written with intertwining jumps or gotos producing "spaghetti" code which is difficult to both read and maintain. Structured programming primarily added subroutines and loop control statements and was later extended by procedural programming which primarily added function calls (not to be confused with functional programming) and which also made exception handling that much easier to maintain. This then led to object-oriented programming.

Program in 'c' to find the LCM of any given five numbers?

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.

What is the name of the C compiler used by Linux?

gcc is the most common C-compiler for GNU/Linux platform.

What is use of user defined data in c?

to create user defined functions the user defined data is needed nd its useful to the programmer to create its own data.

Why c language is powerful?

C++ is general-purpose and portable, which is common to many high-level languages, but it excels in terms of performance, comparable to that of assembly language. This is not surprising given the amount of work that goes into optimising the native machine code that the C++ compiler produces.

Java is arguably more popular today (especially with amateur programmers), but it doesn't perform well when compared to C++. This is largely due to the much higher level of abstraction which requires compiled programs to be executed and interpreted by the Java virtual machine. The main advantage of Java is that the abstraction allows Java programs to be run on any platform that supports the JVM without the need to modify the source code and recompile, which is the main disadvantage of C++. However, in terms of performance alone, few languages can compete with C++, hence its huge popularity in the community.

Who is the father is c language?

Sorry to disappoint you, but you cannot father a programming language. But you can invent one, like Dennis Ritchie did with C forty years ago.