15,551 Topics

Member Avatar for
Member Avatar for shkr

hi, i have a file which contains dfca2345f1278aba11110012567ade21 i also have a structure i need to read from file and print the values of struct in decimal form (i.e s.a=3754566469 , similarly b,c,d,e) so i ve come up with only this, i am not getting how to populate struct and …

Member Avatar for deceptikon
0
136
Member Avatar for delta_frost

Which of the following code is likely to take less time to get executed? /*Format 0*/ main(){ int a=3,b=5; printf("%d",a*b); } /*Format 1*/ int mult(int a,int b){ return a*b; } main(){ printf("%d",mult(3,5)); } /*Format 2*/ inline int mult(int a,int b){ return a*b; } main(){ printf("%d",mult(3,5)); } As of now,I understand …

Member Avatar for deceptikon
0
187
Member Avatar for vaayaa1

int a = 10; int b = ++a++; printf(b); The code when compied shows lvalue error.

Member Avatar for WaltP
0
122
Member Avatar for samohtvii

Hi all, I have a simple program: #include<iostream> using namespace std; 6 int main() { char x; do { scanf("%c", x); } while (x != 'y'); return 0; } and for some reason when i gcc test.c i get "test.c:1:20: fatal error: iostream: No such fiel or directory compilation terminated." …

Member Avatar for Ancient Dragon
0
716
Member Avatar for rithish

#include<stdio.h> void quicksort(int [10],int,int); int main(){ int x[20],size,i; printf("Enter size of the array: "); scanf("%d",&size); printf("Enter %d elements: ",size); for(i=0;i<size;i++) scanf("%d",&x[i]); quicksort(x,0,size-1); printf("Sorted elements: "); for(i=0;i<size;i++) printf(" %d",x[i]); return 0; } void quicksort(int x[],int first,int last){ int pivot,j,temp,i; if(first<last){ pivot=first; i=first; j=last; while(i<j){ while(x[i]<=x[pivot]&&i<last) i++; while(x[j]>x[pivot]) j--; if(i<j){ temp=x[i]; x[i]=x[j]; …

Member Avatar for maurya10
0
342
Member Avatar for I_m_rude

Can anyone tell me the best way to check the number of bits in a number ? for ex, in 2 set bits are1 , in 3 it is 2. So what is best way today available so as to get that value ? thanks. just give me link of …

Member Avatar for I_m_rude
0
107
Member Avatar for Vish0203

What would be the error code for this?? Am I using perror() at right place?? The output shows "No error" #include <stdio.h> #include <conio.h> #define MAX_VAL 32000 int main() { start: int x; printf("Enter a value for x= "); scanf("%d", &x); if (x > MAX_VAL) { perror(""); getch(); system("cls"); goto …

Member Avatar for Vish0203
0
151
Member Avatar for np complete

This is a simple password implementation. void getPassword() { int i = 0, flag = 0 ; char c ; char password[100] ; cout<<"\n Enter Password : " ; while(1) { c = getch() ; if(c! = 13 && c! = 8) { cout<<"*" ; Password[i] = c ; i++ …

Member Avatar for iamthwee
0
418
Member Avatar for raistie_1

Hi all, I am currently trying to generate a number from a specified range using a function int number_range(int from, int to) { return (from + rand() % (to-from+1)); } but negative numbers cause the program to crash. How can i go about doing this so it can take numbers …

Member Avatar for RainbowMatrix
0
261
Member Avatar for I_m_rude

http://www.spoj.pl/problems/BISHOPS/ hey, Can any one please see this problem and tell me how to deal with number like 10^100 ? Please help me out as it is used in many many problems. thanks in advance to everyone.

Member Avatar for delta_frost
0
116
Member Avatar for I_m_rude

int main() { extern int i; i=20; printf("%d\n",i); } hi.. actually this is asked to me today. In this no i is defined anywhere. only declaration is given in main(). then i was asked when the error will come ? like is it segmentation fault, linking error, complilation error or …

Member Avatar for deceptikon
0
129
Member Avatar for Hyperion101

Hey guys! Need some help with homework again, I have absolutely no idea what this means, could someone explain it to me with some example code? *For the quadratic equation problem, complete the 4th phase: Write the C program according to the algorithm specified in the lesson. File name should …

Member Avatar for Hyperion101
0
137
Member Avatar for nchy13

i am getting weird result here. if condition at line 25 is satisfied only 4 times while reading cpuinfo but **cores** is modified each time while loop iterates. i am not able to think of anything that may cause this. any help of any sort is appreciated. #include <stdio.h> #include …

Member Avatar for nchy13
0
350
Member Avatar for nchy13

evrything was fine until i inserted 100 to 125 lines in code. i am wondering what kv is doing wrong as it is not even printing that version file was opened.. any sort of help is appreciated. files included in the code are given below for reference. proc/version file: ** …

Member Avatar for deceptikon
0
239
Member Avatar for Hyperion101

Hey guys, Here's what I have to do: *Write a program that displays the table of Fahrenheit - Celsius temperatures. The formula is : C = (5/9) (F-32) C - Celsius, F- Fahrenheit The range should be: 0 - 200, where as the step should be set to 20. The …

Member Avatar for Hyperion101
0
657
Member Avatar for maurya10

Here is the c code:- #include<stdio.h> #include<stdlib.h> #include<string.h> int main(int argc,char *argv[]){ if(argc==1){ //default printf("first version\n"); int i,j,k; char line[1024],*str1,*str,str2[1024],ch; FILE *in=fopen("/proc/cpuinfo","r"); i=0; while((fgets(line,1024,in))!=NULL){ // printf("%s",line); str=strtok(line, " :"); if(str!=NULL){ //point 1 if(strcmp(str,"model")==0){ printf("%d %s\n",i,str); //point 2 str=strtok(NULL, " :"); printf("%s\n",str); //printing "name" if(strcmp(str,"name")==0) //point 3 printf("CPU Model:=%s\n",strtok(NULL,":")); } else …

Member Avatar for maurya10
0
279
Member Avatar for nataraja833

Hi All , This is my code snippet [CODE]typedef struct { char *name; } CELL; typedef struct { CELL *cell; char *name; } INST ; int main () { INST **top_inst_list ; int i,j; char string_name[100]; printf("Enter number of insts in design\n") ; scanf("%d",&i); top_inst_list = (INST **)malloc(sizeof(INST*)*i) ; for …

Member Avatar for deceptikon
0
137
Member Avatar for ax33m144

Using C-Programming nested for() loops, write a program that displays all possible combinations of a 6 bit binary number. **Sample Run: 000000, 000001, 000010, 000011, ...........111110, 111111** Can anybody please help me in solving this question?

Member Avatar for I_m_rude
0
2K
Member Avatar for every1play

any idea on how to change strcpy in c++ int main() { //all the winning combination strcpy(winKey[1].key, "123"); strcpy(winKey[2].key, "456"); strcpy(winKey[3].key, "789"); strcpy(winKey[4].key, "147"); strcpy(winKey[5].key, "258"); strcpy(winKey[6].key, "369"); strcpy(winKey[7].key, "159"); strcpy(winKey[8].key, "357"); }

Member Avatar for deceptikon
0
245
Member Avatar for ALMOSTunseen

Got some homework here that I need help with. I've been struggling with trying to get the program to pick out the numbers and compare them using "<" and ">" Write a program that gets a list of integers from the user and computes the minimal and maximal number appearing …

Member Avatar for ALMOSTunseen
0
52
Member Avatar for starkk

main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(“%d%dn”,x,y); } what would be the output? can some one explain it with associativity and operator precendence

Member Avatar for WaltP
0
85
Member Avatar for jayram.chandan

# Help me in solving this puzzle people # Interviewstreet Challenge • Challenges /Manipulative Numbers • Rank: 103 Score: 717.63 Suppose that A is a list of n numbers ( A1, A2, A3, ... , An) and B ( B1, B2, B3, .. ,Bn ) is a permutation of these …

Member Avatar for WaltP
0
137
Member Avatar for simps0n

Hello, guys! I have the following code:[CODE]#include<stdio.h> #include<string.h> #include<stdlib.h> struct list_word { char word[64]; struct list_word * next; }; typedef struct list_word itemWord; int main() { itemWord * curr, * head; fill list with words [B]remove duplicates[/B] show final list of words return(0); }[/CODE]So I experience difficulties when implementing the …

Member Avatar for rubberman
0
342
Member Avatar for jayram.chandan

#include <stdio.h> #include <stdlib.h> long i,j,k,*ni,qi,a,*arr,n,q,p,no,c=0,m,max=0; int main() { ni = malloc(sizeof(long) * 100000); arr=malloc(sizeof(long)*10000); scanf("%ld",&no); for(i=1;i<=no;i++) { scanf("%ld %ld",&n,&qi); for(j=1;j<=n;j++) { scanf("%ld",&ni[j]); } for(k=1;k<=qi;k++) { scanf("%ld %ld %ld",&a,&p,&q); while(p<=q) { arr[++c]=ni[p++]^a; } for(m=1;m<=c;m++) { if(arr[m]>max) { max=arr[m]; } } printf("\n%ld",max); max=0; c=0; } } return 0; } Bold Text …

Member Avatar for jayram.chandan
-1
235
Member Avatar for modesto916

Hi, I have a homework to do for college, which asks me to write a pascal lexical analizer in C. I'm trying to figure out the best way to ignore the comments, so far I've written this code, which works, but I would like to know if there is an …

Member Avatar for modesto916
0
255
Member Avatar for ripplex

int a; scanf("%c",&a); printf("%d",a); i/p:12,13,14,15,16 o/p:1963761201 i/p:65 o/p:1963761206 Please explain to the reason for this output?

Member Avatar for ripplex
0
92
Member Avatar for Vish0203

while((c=getch())!=13) { pass[z++]=c; printf("%c",'*'); } I used this while loop to take the input of the password. Everything works fine until no "wrong" key is pressed. the problem is, suppose, if i press a wrong key n i want to delete it (backspace) then even backspace is taken as a …

Member Avatar for Vish0203
0
122
Member Avatar for infrapt

I have a a few callback functions. i need to register them as a list. And callback all the registered functions in a main after a certain task is done. I am new to callback functions. Please shed some insight on this xcallback(register_callbackfunctions); ycallback(register_callbackfunctions); register_callbackfunctions()//not too sure what goes in …

Member Avatar for infrapt
0
3K
Member Avatar for I_m_rude

we are getting i/p of 5,00,000 numbers ranging from 0 to 10^9 one by one. all numbers appears twice except one. We have to tell that number in the most efficient way. Any idea or just a hint to get this ? no code, no algo nothing i want. i …

Member Avatar for Ancient Dragon
0
99
Member Avatar for aratnon

sorry i'm new at c i want to read these data from txt file. A 7 c 5 y 6 U 9 j 4 Z 3 z 5 0 here is my code while(feof(input)==0){ char c; int num; fscanf(input,"%c%d",&c,&num); printf("%c:%d\n",c,num); } but result in console is not same as txt …

Member Avatar for deceptikon
0
239

The End.