Reputation: 43
#include <stdio.h>
#include<stdlib.h>
int main(void){
int n1,k1;
int tot;
scanf("%d",k1);
scanf("%d",n1);
tot=((k1=1)?((n1(n1+1))/2):((n1(n1+1))/2)-((k1(k1+1))/2));
return 0;
}
this code is wrong?
Compiling it with Dev c++, gives me the error "called object is not a function" refered at
tot=((k1=1)?((n1(n1+1))/2):((n1(n1+1))/2)-((k1(k1+1))/2));
Upvotes: 1
Views: 74
Reputation: 11071
First of all you should pass the pointers to variables to the scanf
functions using &
operator:
scanf("%d",&k1);
scanf("%d",&n1);
Secondly, you should correct mistakes in the syntax of your expression:
==
instead of =
to check equality *
operator if you want to perform the multiclication.tot=((k1==1)?((n1*(n1+1))/2):((n1*(n1+1))/2)-((k1*(k1+1))/2));
Upvotes: 1