Write a program to convert numbers into words?For ex: 547five hundred and forty seven
What is the output of the following program:
a) 260 b) 0 c) -1 d) 1Code
int main() { char a = 120, b = 140; int i; i = a + b; return 0; }
it will be 4;
der is no any option unfortunately;
bcoz a=120 and b=140 but b can,t exceed 127. after 127 it will be -128,-127,-126.......up to -116;
so updated a and b will be 120, -116 respectively;
so final value will be 4:
a
Removing duplicate words from a string
This is giving me runtime error why ?Code
int main() { char arr[1000]; char *temp=NULL; char *temp1=malloc(100); int len; "); gets(arr); len=strlen(arr); puts(arr); ",len); temp=strtok(arr," "); if(temp!=NULL) strcpy(temp1,temp); while(temp!=NULL) { temp=strtok(NULL," "); if(strstr(temp1,temp)==NULL) { strcat(temp1," "); strcat(temp1,temp); } } strcpy(arr,temp1); return 0; }
You need to check that temp isnt null after the call to strtok() in the loop. See the attachment for a fix.
Code
temp = strtok(NULL, " "); if (temp != NULL && strstr(temp1,temp) == NULL)
wild pointer is a pointer which has not been initialized i.e point to nothing
A pointer which does not hold any valid address is called wild pointer
Difference between printf and cprintf
What is the difference between cprintf and printf? Please explain in detail.
cprintf outputs to the console device.
fprintf outputs to a stream specified by the 1st parameter.
printf outputs to the standard output stream (stdout)
fprintf goes to a file handle (FILE*)
sprintf goes to a buffer you allocated. (char*)
What will be output if you will execute following C code?
a) 1.000000 b) 0.333333 c) -2.333333 d) 1Code
#i ain() { float p=1,q=2,r=-2,a; a=avg(p,(q=4,r=-12,q),r); } float avg(float x,float y,float z) { return (x+y+z)/3; }
The real answer is that any programmer who would write this kind of code should be given the opportunity to work for the competition.
The sequence expression (q=4,r=-12,q) evaluates to 4 (the last element), with the side-effect of assigning r the value -12. So, avg(1,4,-12) = -7/3 = -2.33...
avg(1,-6,-2)/3 =-2.3333
Write a program to implement the fibonacci series
limit:5
01123
A) trueb) false
A) True
We cannot read the data using fread() function that was written in to file using fwrite() function. This is so beacause the file pointer (FILE* fp) that was passed as the argument of the fread() funct...
Write a program in C to find the 3*3 matrix multiplication
Check this out:
Code
int a[3][3],b[3][3],c[3][3]; int i,j,k; "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&a[i][j]); } } "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&b[i][j]); } } for(i=0;i<=2;i++) { "); for(j=0;j<=2;j++) { c[i][j]=0; for(k=0;k<=2;k++) { c[i][j] = c[i][j]+a[i][k] * b[k][j]; } } } "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { } "); }
Code
main() { int a[10][10],b[10][10],c[10][10]: int i,j,k; for(i=0;i<=5;i++) for(j=0;j<+5;j++) { scanf("%d",&a[i][j]); } for(i=0;i<=5;i++) for(j=0;j<+5;j++) { scanf("%d",&b[i][j]); } c[0][0]=0; for(i=0;i<=5;i++) { [ this is main logic ] for(j=0;j<=5;j++) { for(k=0;k<=5;k++) { c[i][j]=c[i][j]=c[k][j]+a[i][k]*b[k][j]; } } for(i=0;i<=5;i++) for(j=0;j<=5;j++) }
What is the output of the program
Code
#include<stdio.h> int main() { return 0; }
here in printf %c is consider for only a character not for a string so it will print only first letter or character of string i.e a
Answer is a
What is the difference b/w C & Java?
There are many differences beyond syntax. C compiles to a native binary, whereas Java compiles to a bytecode that is interpreted by a virtual machine (typically). C leaves a lot of details such as t...
What is the difference between getch() and getche()?
Both getch() and getche() are used to read single character there is very little difference -getch() doesnt display output to screen if used without lvalue -getche() display output to screen even ...
a) return fib(n) + fin(n-1); b) return fib(n-1) + fin(n-2); c) return fib(n) + fin(n+1); d) return fin(n-1);Code
#include <stdio.h> int fib(n){ if (n <= 2) return 1; else // insert here }
If a,b,c are int variables and a=2, b=4,c=3,d=5, what is the value of the expression
A/b/c*d-a+c*d/b-c. Justify your answer
The answer is -2.
Expressions are calculated from left to right and so we have:
a/b=1, (a/b)/c=0 (rounding down).
c*d/b is also calculated the same way to give 3.
So -2+3-3 = -2
Some operating systems (such as UNIX or windows in enhanced mode) use virtual memory. Virtual memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate ram (random-access memory). In the 80386 and higher intel cpu chips, and in most...
Thrashing is caused by under allocation of the minimum number of pages required by a process, forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU util...
First of all there is a one sentence definition of Page Thrashing (I believe someone posted a similar answer here):Page Thrashing only comes about when you use Virtual Memory which requires an MMU and...
What change is required in the following program so that its output becomes 3,6,11,20,37,......1034?
Code
#include<stdio.h> #include<math.h> int main() { int a=1,r=2,i; for (i=0;i<=10;i++) return 0; }
Code
#include<stdio.h> #include<conio.h> int main() { int r=2,i,a; for(i=1,a=1;a<10,i<10;a++,i++) { } return 0; }
Find the errors in the following program:
Code
# include<stdio.h> int main() { a difficult task"); return(); }
Return should contain return(0) because return type of main is int.
b) float pointer
b is a plain float.
FLOATPTR a,b; expands to float* a,b;, which is *parsed* as float (*a),b;. The * is bound to the declarator, not the type specifier, so only a is declared as a pointer to float.
Cprintf is defined to send formatted output to the text window on the screen. And printf directs its output to the stdout. What is the difference between stdout and a text window then? Does the screen serve differently while using cprintf and printf? Please explain
The following handles up to 32-bit integer values. Not the prettiest code in the world, but it works pretty well. Sample output: [fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 1 one [fbgo448@n9...
"c #include #include void pw(long,char[]); char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen...